<template>
    <div>
        <my-dialog :is-show="isShowCheckDialog" @on-close="checkStatus">
            请检查你的支付状态
            <div class="button" @click="checkStatus">
                支付成功
            </div>
            <div class="button" @click="checkStatus">
                支付失败
            </div>
        </my-dialog>
        <my-dialog :is-show="isShowsuccessDialog" @on-close="toOrderList">
            购买成功！
        </my-dialog>
        <my-dialog :is-show="isShowFailDialog" @on-close="toOrderList">
            购买失败！
        </my-dialog>
    </div>
</template>
<script>
import MyDialog from '../components/base/dialog'
export default {
    props: {
        isShowCheckDialog: {
            type: Boolean,
            default: false
        },
        orderid: {
            type: [String, Number]
        }
    },
    data () {
        return {
            isShowsuccessDialog: false,
            isShowFailDialog: false
        }
    },
    methods: {
        checkStatus () {
            let _self = this
            this.$http.post('/api/checkOrder',{
                orderId: this.orderid
            }).then((res) => {
                _self.isShowSuccessDialog = true
                this.$emit('on-close-check-dialog')
            }, (err) => {
                this.isShowFailDialog = true
                this.$emit('on-close-check-dialog')
            })
        },
        toOrderList () {
            this.$router.push({path: '/orderlist'})
        }
    },
    components: {
        MyDialog
    }
}

</script>
<style>

</style>
